/*
 * @Author: hucc
 * @Date: 2021-09-27 09:37:56
 * @LastEditors: hucc
 * @LastEditTime: 2021-10-05 19:40:30
 * @Description: 
 */
//箭头函数的this指向声明时外部作用域的this,与调用者无关
let arrowFun = () => {
    console.log(this); //指向全局 现在全局是{ name: 'lisi' }
}
let obj = {
    name: "zs",
    age: 12,
    gender: "male",
    // sayName:function(){}
    //对象里函数简写 sayName(){}
    // sayName() {
    //     console.log(this.name);//zs
    // }
    // sayName: () => {
    //         console.log(this);
    //     }
    sayName() {
        return () => {
            console.log(this); //指向obj
        }
    }
    // sayName() {
    //     return arrowFun;
    // }
}
this.name = 'lisi'
    //全局this等价于当前commonjs模块的默认导出module.exports
console.log("全局", this, module.exports); //全局 { name: 'lisi' } { name: 'lisi' }
// module.exports={
//     a:1,
//     b:2
// }  改变了module.exports的this指向
//不改变的话可以这么写module.exports.gender="male" 输出结果是{name:'lisi',gender:'male'}
obj.sayName()();
//obj.sayName();
arrowFun();